<?php
/**
 * 频道
 */
require_once dirname(dirname(__DIR__))."/common.php";
//require_once dirname(__DIR__)."/login_filter.php";
use app\cls\tom\Response;
use app\cls\tom\SysResource;
use app\model\HomePage;

//先从缓存里读取数据
$redis = SysResource::getRedis();
$redis_cache_key=REDIS_PREFIX."HOME_PINDAO_";
$redis_cache_data=$redis->get($redis_cache_key);
if($redis_cache_data){
    //读取缓存里的数据
    $data=json_decode($redis_cache_data);
    Response::output(0,"查询成功1",$data,count($data));
}else {
    //查询数据库
    $db = SysResource::getDB(false);
    $HomePage = new HomePage($db);
    //先去查询有几个频道
    $res1=$HomePage->get_pindao();
    if(!empty($res1)){
        $redis->setex($redis_cache_key,15,json_encode($res1));
        Response::output(0,"",$res1,count($res1));
    }else{
        Response::output(0,"",[],0);
    }

}

